﻿using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class Data_Contact : Data
    {
        #region [Contact_Insert]
        public void Contact_Insert(Contact data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_Contact_Insert", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@ID", data.ID);
                cmd.Parameters.Add("@Name", data.Name);
                cmd.Parameters.Add("@Address", data.Address);
                cmd.Parameters.Add("@Phone", data.Phone);
                cmd.Parameters.Add("@Email", data.Email);
                cmd.Parameters.Add("@Detail", data.Detail);
                cmd.Parameters.Add("@Date", data.Date);

                cmd.ExecuteNonQuery();
            }
        }
        #endregion



        #region [Contact_GetByAll]
        public DataTable Contact_GetByAll()
        {
            using (SqlCommand cmd = new SqlCommand("sp_Contact_GetByAll", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                return dt;
            }
        }
        #endregion
    }
}
